package cn.iocoder.yudao.module.controller;


import cn.iocoder.yudao.module.VO.ScoreVo;
import cn.iocoder.yudao.module.pojo.Score;
import cn.iocoder.yudao.module.service.ScoreService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.security.PermitAll;

@RestController
@Slf4j
@Tag(name="成绩信息管理")
@RequestMapping("/admin-api/edu/score")
public class ScoreController {
    @Autowired
    private ScoreService scoreService;
    @PermitAll
    @PostMapping("addScore")
    @Operation(summary = "成绩添加")
    public CommonResult addScore(@RequestBody ScoreVo score) {
        scoreService.saveScore(score);
        return CommonResult.success("true");
    }
    @PermitAll
    @PutMapping("updateScore")
    @Operation(summary = "成绩更改")
    public CommonResult updateScore(@RequestBody ScoreVo score) {
        scoreService.updateScore(score);
        return CommonResult.success("true");
    }
    @PermitAll
    @DeleteMapping ("deleteScore")
    @Operation(summary = "成绩删除")
    public CommonResult deleteScore(@RequestBody ScoreVo score) {
        scoreService.deleteScore(score);
        return CommonResult.success("true");
    }
    @PermitAll
    @GetMapping("getScore")
    @Operation(summary = "成绩查询")
    public CommonResult getScore(Long id) {
        Score score = scoreService.getScoreById(id);
        return CommonResult.success(score);
    }
}
